﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RoleClassViewModel.cs" >
//   J. Prinz
// </copyright>
// <summary>
//   ViewModel representing a RoleClass <see cref="RoleClassType" />
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace AutomationMLMapper.ViewModels.CAEXObjectViewModels
{
    using CAEX_ClassModel;
    using AutomationMLMapper.AutomationML.Extensions;
    using System.Xml;
    using System.Linq;

    /// <summary>
    ///   ViewModel representing a RoleClass <see cref="RoleClassType" />
    /// </summary>
    public class RoleClassViewModel : CAEXObjectWithAttributesViewModel<RoleClassType>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="RoleClassViewModel"/> class. 
        /// </summary>
        /// <param name="element">
        /// a CAEX - RoleClassType-Element 
        /// </param>
        public RoleClassViewModel(RoleClassType element)
            : base(element)
        {
            this.AttributesCollection.AllowEditElement = false;
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///   DisplayName of the CAEX-Element in the UI used in Headers and Labels
        /// </summary>
        public static new string DisplayName
        {
            get
            {
                return "RoleClass";
            }
        }


        /// <summary>
        /// get the Comparer Result from the current Comparer Dictionary
        /// </summary>
        public CaexObjectComparerResult ComparerResult  
        {
            get
            {
                if (CaexObjectComparer.CaexComparedObjects != null)
                {
                    var list = CaexObjectComparer.DifferentRoleClassTypes();
                    if (list != null)
                    {
                        var result = list.SingleOrDefault
                            (t => t.Item1.CaexEquals(this.CaexObject, false) == CaexObjectComparerResult.IsEqual);
                        
                        if (result != null) 
                             return result.Item3;
                    }
                }
                return CaexObjectComparerResult.IsEqual;
            }
        }


        public string ComparerResultString
        {
            get
            {
                return CaexObjectComparer.CaexObjectComparerResultString(this.ComparerResult);
            }
        }

        #endregion
    }
}